package cn.sumpu.app.guoguojie.biz;

import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import com.taobao.api.domain.TaobaokeItem;

import cn.sumpu.app.guoguojie.domain.Comment;
import cn.sumpu.app.guoguojie.domain.Doing;
import cn.sumpu.app.guoguojie.domain.DoingPicture;
import cn.sumpu.app.guoguojie.domain.DoingProduct;
import cn.sumpu.app.guoguojie.domain.DoingProductTime;
import cn.sumpu.app.guoguojie.domain.DoingTopic;
import cn.sumpu.app.guoguojie.domain.DoingTopicRelation;
import cn.sumpu.app.guoguojie.domain.Member;
import cn.sumpu.app.guoguojie.domain.Ext.DoingExt;
import cn.sumpu.app.guoguojie.util.AlertMsg;
import cn.sumpu.app.guoguojie.util.PageModel;
import cn.sumpu.app.guoguojie.util.ProductBs;
import cn.sumpu.app.guoguojie.exception.AppBusinessException;

public interface DoingBiz {
    public ProductBs getProductInfo(String url) throws Exception;

    public void insert(Doing doing) throws AppBusinessException;

    /**
     * 发布微博商品.
     * 
     * @author nick
     * @param doing 微博
     * @param doingProduct 微博商品
     * @param ip 发布ip
     * @param isShare 是否同步分享微博商品
     * @param member 发布会员
     * @return 发布后的提示消息
     * @throws AppBusinessException 发布失败
     */
    public AlertMsg postDoingProduct(Doing doing, DoingProduct doingProduct, String ip, Boolean isShare, Member member) throws AppBusinessException;

    public void update(Doing doing) throws AppBusinessException;

    public Doing getDoingById(String id) throws AppBusinessException;

    public Doing getRootDoingById(String id) throws AppBusinessException;

    public Doing getDoingByMember(String member) throws AppBusinessException; // 取得这个会员最后一次发微博的

    public Doing getDoingByFamily(String member) throws AppBusinessException; // 取得这个家最后一次发微博的

    public List<Doing> getDoingList(Map<String, Object> map) throws AppBusinessException;

    public void deleteDoing(String family, String id) throws AppBusinessException;

    public PageModel getDoingModel(String family, Integer page) throws AppBusinessException;

    public int getDoingListCount(String family) throws AppBusinessException;

    public List<DoingExt> getDoingByTopic(Map<String, Object> map) throws AppBusinessException;

    public void insertTopic(DoingTopic doingTopic) throws AppBusinessException;

    public void insertTopicRelation(DoingTopicRelation topicRelation) throws AppBusinessException;

    public int getDoingCountByTopic(Map<String, Object> map) throws AppBusinessException;

    /**
     * 转发微博
     * 
     * @param forwardId
     *            转发的微博ID
     * @param content
     *            内容
     * @param member
     *            会员对象
     * @throws AppBusinessException
     */
    public void doingForward(String forwardId, String content, boolean commentFamily, boolean commentRootFamily, Member member, String ip)
                                                                                                                                          throws AppBusinessException;

    /**
     * 搜索匹配关键词的微博，然后进行分页显示.
     * 
     * @param page
     *            当前是第几页
     * @param keywords
     *            关键词
     * @return 内容匹配关键词的微博
     * @throws AppBusinessException
     */
    public PageModel getDoingByKeywords(Integer page, String keywords) throws AppBusinessException;

    /**
     * author Bruce Zhang
     * 
     * @return 取得20个家庭最新的的一条微博
     * @throws AppBusinessException
     */
    public List<Doing> getDoingNewest() throws AppBusinessException;

    /**
     * author Bruce Zhang
     * 
     * @param map
     *            参数集合（1.doorplate:门牌号 2.title:图片标题 3.startTime:开始时间
     *            4.endTime:结束时间 5.page:页码）
     * @return 根据条件查询微博列表
     * @throws AppBusinessException
     */
    PageModel getDoingByCondition(String keyword, String keywordType, String product, String type, String startTime, String endTime, Integer page, String isPage)
                                                                                                                                                                 throws AppBusinessException;

    PageModel getDoingStat(String type, String startTime, String endTime, Integer page, Integer pageSize, String sort, String orderby)
                                                                                                                                      throws AppBusinessException;

    // 根据DoingId集合批量屏蔽微博
    void updateByDoingIdList(String idList, Boolean enabled) throws AppBusinessException;

    // 根据DoingId集合批量删除微博
    void deleteByDoingIdList(String idList) throws AppBusinessException;

    // 根据微博的标签查询微博
    PageModel getDoingListByTag(String systemTag, Integer page, String doingId, Integer times, Integer minPrice, Integer maxPrice) throws AppBusinessException;

    PageModel getDoingListByTagBruce(String systemTag, String doingId, Integer size, String time) throws AppBusinessException;

    // 根据微博的标签查询微博总条数
    Integer getDoingCountByTag(String tag, Date delayTime, Integer minPrice, Integer maxPrice) throws AppBusinessException;

    // 根据微博的ID取得两条该微博的评论
    List<Comment> getCommentListByDoing(String doingId) throws AppBusinessException;

    // 根据频道查询商品列表
    PageModel getDoingListByChannel(String channel, String systemTag, Integer page, Integer times, Integer minPrice, Integer maxPrice)
                                                                                                                                      throws AppBusinessException;

    PageModel getDoingListByChannelBruce(String channel, String systemTag, Integer size, String time) throws AppBusinessException;

    // 根据频道查询商品列表长度
    Integer getDoingCountByChannel(String channel, String systemTag, Integer minPrice, Integer maxPrice) throws AppBusinessException;

    // 童鞋配饰的格子
    List<Doing> getDoingGrid(String sql) throws AppBusinessException;

    // 根据频道查询帖子
    List<Doing> getPostsListByChannel(String channel, String status, Integer number) throws AppBusinessException;

    /**
     * 得到微博的商品信息
     * 
     * @param doing
     * @return
     * @throws AppBusinessException
     */
    public List<DoingProduct> getDoingProductList(String doing) throws AppBusinessException;

    /**
     * 插入微博的商品信息
     * 
     * @param doingProduct
     * @throws AppBusinessException
     */
    public void insertDoingProduct(DoingProduct doingProduct) throws AppBusinessException;

    /**
     * 删除微博下的所有商品信息
     * 
     * @param doing
     * @throws AppBusinessException
     */
    public void deleteDoingProduct(String doing) throws AppBusinessException;

    /**
     * 得到微博的图片信息
     * 
     * @param doing
     * @return
     * @throws AppBusinessException
     */
    public List<DoingPicture> getDoingPictureList(String doing) throws AppBusinessException;

    /**
     * 插入微博的商品信息
     * 
     * @param doingPicture
     * @throws AppBusinessException
     */
    public void insertDoingPicture(DoingPicture doingPicture) throws AppBusinessException;

    /**
     * 删除微博下的所有商品信息
     * 
     * @param doing
     * @throws AppBusinessException
     */
    public void deleteDoingPicture(String doing) throws AppBusinessException;

    /**
     * 微博页面的数据
     * 
     * @param ownerType
     * @param request
     * @throws AppBusinessException
     */
    public void enterWeiBo(String ownerType, HttpServletRequest request) throws AppBusinessException;

    /**
     * 我家微博动态
     * 
     * @param ownerType
     * @param request
     * @throws AppBusinessException
     */
    public void familyDoing(Integer page, HttpServletRequest request) throws AppBusinessException;

    /**
     * 得到我家的关注的数量
     * 
     * @param family
     * @return
     * @throws AppBusinessException
     */
    public int getFollowCount(String family) throws AppBusinessException;

    /**
     * 得到我家的粉丝的数量
     * 
     * @param family
     * @return
     * @throws AppBusinessException
     */
    public int getFansCount(String family) throws AppBusinessException;

    /**
     * 取消关注
     * 
     * @param family
     * @param follow
     * @throws AppBusinessException
     */
    public void cancelFollow(String family, String follow) throws AppBusinessException;

    /**
     * 添加关注
     * 
     * @param family
     * @param follow
     * @throws AppBusinessException
     */
    public void addFollow(String family, String follow, String member) throws AppBusinessException;

    /**
     * 移除粉丝
     * 
     * @param family
     * @param follow
     * @throws AppBusinessException
     */
    public void removeFans(String family, String fans) throws AppBusinessException;

    /**
     * 得到我关注的列表
     * 
     * @param page
     * @param family
     * @return
     * @throws AppBusinessException
     */
    public PageModel getFollowList(Integer page, String taFamily, String meFamily) throws AppBusinessException;

    /**
     * 得到我的粉丝列表
     * 
     * @param page
     * @param family
     * @return
     * @throws AppBusinessException
     */
    public PageModel getFansList(Integer page, String taFamily, String meFamily) throws AppBusinessException;

    /**
     * 得到我关注的人发表的微博包括我自己发的微博
     * 
     * @param page
     * @param family
     * @return
     * @throws AppBusinessException
     */
    public PageModel getFollowDoingList(Integer page, String family) throws AppBusinessException;

    /**
     * 我关注的人的所有微博包括我的微博列表
     * 
     * @param page
     * @param request
     * @throws AppBusinessException
     */
    public void followDoingList(Integer page, HttpServletRequest request) throws AppBusinessException;

    /**
     * @param idList
     * @param page
     * @return
     * @throws AppBusinessException
     */
    PageModel getDoingListByIds(Set<String> idList, Integer page) throws AppBusinessException;

    public PageModel getTCoverFeed(String family) throws AppBusinessException;// 得到他家封面的分享动态

    public PageModel getCoverTypeByMyFamily(String family, String type, Integer page) throws AppBusinessException;// 他家封面宝贝相册

    PageModel getDoingListByDoingIds(Set<String> idList, Integer page) throws AppBusinessException;

    public PageModel getProductListByProductIds(Set<String> idList, Integer page) throws AppBusinessException;// 传一批产品Id得到产品列表

    public int isFollowMe(String myFamily, String taFamily) throws AppBusinessException;// 是否关注

    public PageModel getDoingByMyFamily(String family, Integer page) throws AppBusinessException;// 我家发表的

    public PageModel getMentionMyFamilyDoing(String family, Integer page) throws AppBusinessException;// 提到我家的

    public List<DoingProduct> getOtherLoveDoing(String doingId) throws AppBusinessException;// 喜欢这个的人还喜欢

    public PageModel getForwardDoingList(String rootId, Integer page) throws AppBusinessException;// 转发列表

    public String shareWeibo(String doingId, String weiboType) throws AppBusinessException;//分享微博

    public DoingProduct getProductById(String id) throws AppBusinessException;

    public DoingPicture getPictureById(String id) throws AppBusinessException;

    public void post2Weibo(String content, String picurl) throws AppBusinessException;

    //	得到分享的数目
    public int getShareCount(String family) throws AppBusinessException;

    public void insertDoingStat(String ip, String doing) throws AppBusinessException;

    //查询这条微博有几个图片
    int getPicCountByDoing(String doingId) throws AppBusinessException;

    //查询这条微博有几个商品
    int getProCountByDoing(String doingId) throws AppBusinessException;

    //查询这条微博画报号
    String getPictorialByDoing(String doingId) throws AppBusinessException;

    public void setLinkUrlTaobao() throws AppBusinessException;

    //查询家发的商品数
    public int getDoingProCount(String family) throws AppBusinessException;

    //查询家发的图片数
    public int getDoingPicCount(String family) throws AppBusinessException;

    //查询家回帖数
    public int getMyRelpycCount(String family) throws AppBusinessException;

    //查询家回的帖子的沙发贴
    public List<Doing> getMyRelpy(String family) throws AppBusinessException;

    //查询满足创建5个画报，每个画报内至少添加过一个内容的记录数
    public int getMyPictorialBadge(String family) throws AppBusinessException;

    public DoingProduct getDoingProductById(String id) throws AppBusinessException;

    public DoingPicture getDoingPictureById(String id) throws AppBusinessException;

    public String doingDetail(String doingId, String proId, String picId, HttpServletRequest request) throws AppBusinessException;

    /**
     * author BruceZhang
     * @param id	商品ID
     * @return	根据商品Id查询产品的所有属性
     * @throws AppBusinessException
     */
    DoingProduct getDpById(String id) throws AppBusinessException;

    /**
     * author BruceZhang
     * @param map	startTime：开始时间 endTime：结束时间 pictorial：所属画报
     * @return	查询画报的商品(后台ETAO)
     * @throws AppBusinessException
     */
    List<DoingProduct> getProductByPictorial(String startTime, String endTime, String pictorial) throws Exception;

    /**
     * author Bruce Zhang
     * @param from         来源
     * @param originalId   原始ID
     * @return 查询这个商品是否被分享过
     * @throws AppBusinessException
     */
    DoingProduct getProductContain(String from, String originalId) throws AppBusinessException;

    /**
     * author Bruce Zhang
     * @param from         来源
     * @param tbks         淘宝客集合
     * @return 查询这个商品是否被分享过
     * @throws AppBusinessException
     */
    void getProductsContain(String from, List<TaobaokeItem> tbks) throws AppBusinessException;

    /**
     * @author BruceZhang
     * @param product   商品信息
     * @return          切割商品图片并返回商品信息
     * @throws AppBusinessException 切割失败
     */
    DoingProduct cutImg(DoingProduct product, String memberId) throws AppBusinessException;

    /**
     * author BruceZhang
     * @param product   商品
     * @return  添加商品
     * @throws AppBusinessException
     */
    DoingProduct addProduct(DoingProduct product) throws AppBusinessException;

    /**
     * author BruceZhang
     * @param product   商品
     * @return  更新商品
     * @throws AppBusinessException
     */
    void updateDoingProduct(DoingProduct product) throws AppBusinessException;

    /**
     * 发布限时返利商品.
     * 
     * @author nick
     * @param doingProductTime 限时返利商品
     * @throws AppBusinessException 发布失败
     */
    void postDoingProductTime(DoingProductTime doingProductTime) throws AppBusinessException;

    /**
     * 检查某个商品是否正在搞限时返利活动.
     * 
     * @author nick
     * @param doingProductTime 限时返利商品
     * @return 正在做活动返回true，否则返回false
     * @throws AppBusinessException 检查失败
     */
    boolean checkDoingProductTime(DoingProductTime doingProductTime) throws AppBusinessException;

    PageModel getFanliProduct(Integer page) throws AppBusinessException;

    /**
     * author BruceZhang
     * @param pid   商品ID
     * @param request
     * 商品底层页方法
     */
    void productDetail(String pid, HttpServletRequest request) throws AppBusinessException;

    PageModel getProductByCondition(String id, String name, String startTime, String endTime, Integer page) throws AppBusinessException, ParseException;

    List<DoingProductTime> getFanliProduct(String channel, int nums) throws AppBusinessException;

    /**
     * author BruceZhang
     * @param love 喜欢   
     * 更新微博的量值(+1)
     * @throws AppBusinessException
     */
    public void updateDoingAdd(String Doing, Integer love) throws AppBusinessException;

    /**
     * 查看指定的产品当前是否正在做返利活动.
     * 
     * @param productId
     * @return
     * @throws AppBusinessException
     */
    public DoingProductTime getHasProductTime(String productId) throws AppBusinessException;

    //查询微博
    List<Doing> getDoingBruce(String time) throws AppBusinessException;

    //查询商品
    List<DoingProduct> getProductBruce(String time) throws AppBusinessException;

    //修改数量
    void updateNumberBruce(String type, String time, Integer number) throws AppBusinessException;
//    得到EDM的返利产品列表
    public List<DoingProductTime> getEdmProduct() throws AppBusinessException;

}
